package com.fzt.system.controller;

import com.fzt.common.constant.MenuTypeEnum;
import com.fzt.common.utils.R;
import com.fzt.framework.user.SecurityUser;
import com.fzt.framework.user.UserDetail;
import com.fzt.system.domain.vo.SysMenuVO;
import com.fzt.system.service.SysMenuService;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 * 菜单管理
 * </p>
 *
 * @author 非洲铜
 * @since 2022-12-11
 */
@RestController
@RequestMapping("/sys/menu")
@AllArgsConstructor
public class SysMenuController {
    private final SysMenuService sysMenuService;

    @GetMapping("/tree")
    public R<List<SysMenuVO>> tree() {
        UserDetail      user         = SecurityUser.getUser();
        List<SysMenuVO> userMenuTree = sysMenuService.getUserMenuTree(user, MenuTypeEnum.MENU.getValue());
        return R.ok(userMenuTree);
    }
}
